﻿Imports System.Data.OleDb
Imports System.Data.OracleClient
Imports System.IO
Imports ccapps.persistent.LAPoful

Public Class LA_Poful
    Inherits System.Web.UI.Page


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim dt As DataTable = ReasonList()

        If dt.Rows.Count > 0 Then
            For Each dr As DataRow In dt.Rows
                DropDownList6.Items.Add(New ListItem(dr("RS_DESC").ToString(), dr("RS_ID").ToString()))
            Next
        End If


    End Sub

    Protected Sub btnDogrula(sender As Object, e As EventArgs) Handles Button4.Click
        Table2.Visible = False
        Table3.Visible = False
        Table4.Visible = False
        Us.Visible = True


        Dim dt As DataTable = GetCustomerInfoFromCustcode(txtMusteriKodu.Text.Trim())
        If dt.Rows.Count > 0 Then
            DropDownList2.Visible = True
            Label1.Text = dt.Rows(0)("CCFNAME").ToString() + " " + dt.Rows(0)("CCLNAME").ToString() + " " + dt.Rows(0)("CCCITY").ToString()
            Label2.Text = dt.Rows(0)("CUSTOMER_ID").ToString()
            If dt.Rows(0)("RPE_LONG_DESC").ToString() = "" Or dt.Rows(0)("RPE_LONG_DESC").ToString() Is Nothing Then
                lblMevcutPoful.Text = "--------"
            Else
                lblMevcutPoful.Text = dt.Rows(0)("RPE_LONG_DESC").ToString()
                If dt.Rows(0)("STATUS").ToString() = "Active" Then
                    'If 1 = 1 Then
                    '"ONE_TIME_CHARGE",vn_recurring_charge "RECURIING_CHARGE"  
                    Label27.Text = "Aradığınız Custcode Ait Aktif Lapoful Bilgisi Vardır.Yeni Lapoful Ekleyemessiniz!"
                   
                    DropDownList2.Items.Clear()
                    DropDownList2.Items.Add(New ListItem("Mevcut POFUL detay goster"))
                    DropDownList2.Items.Add(New ListItem("Mevcut POFUL sil"))

                Else
                    DropDownList2.Items.Clear()
                    DropDownList2.Items.Add(New ListItem("Mevcut POFUL detay goster"))
                    DropDownList2.Items.Add(New ListItem("Yeni POFUL ekle"))
                    Label27.Text = "Aradığınız Custcode Ait Aktif Lapoful Bilgisi Yoktur. Yeni Lapoful Ekleyebilirsiniz!"
                 
                    'Label27.Text = dt.Rows(0)("STATUS").ToString()

                End If

            End If


        Else
            'lblError.Text = "Aradığınız Custcode Ait Lapoful Bilgisi Bulunamamıştır." + dt.Rows.Count.ToString()

            'lblError.Visible = True
            Dim datatable As DataTable = CustomerInfoFromCustcode(txtMusteriKodu.Text.Trim())
            Label1.Text = datatable.Rows(0)("CCFNAME").ToString() + " " + datatable.Rows(0)("CCLNAME").ToString() + " " + datatable.Rows(0)("CCCITY").ToString()
            Label2.Text = datatable.Rows(0)("CUSTOMER_ID").ToString()
            lblMevcutPoful.Text = "--------"
            DropDownList2.Visible = True
            DropDownList2.Items.Clear()
            DropDownList2.Items.Add(New ListItem("Yeni POFUL ekle"))
            Label27.Text = "Aradığınız CustCode Ait Lapoful Bilgisi Yoktur. Yeni Lapoful Ekleyebilirsiniz"


        End If


    End Sub
    Protected Sub Button3_Click(sender As Object, e As EventArgs)

    End Sub
    Protected Sub btnDevam(sender As Object, e As EventArgs) Handles Button2.Click
        If DropDownList2.SelectedItem.Text = "Yeni POFUL ekle" Then
            Table2.Visible = True
            Table3.Visible = False
            Table4.Visible = False
            Dim rpe_datatable As DataTable = RpeList()
            If rpe_datatable.Rows.Count > 0 Then
                For Each dr As DataRow In rpe_datatable.Rows
                    DropDownList4.Items.Add(New ListItem(dr("DES").ToString(), dr("VALUE").ToString()))
                Next
            End If
            Dim dt As DataTable = GetCustomerInfoFromCustcode(txtMusteriKodu.Text.Trim())
            If dt.Rows.Count > 0 Then
                Label3.Text = dt.Rows(0)("CCFNAME").ToString() + " " + dt.Rows(0)("CCLNAME").ToString()
                Label10.Text = txtMusteriKodu.Text.Trim()
                Label4.Text = Label2.Text
                Label9.Text = dt.Rows(0)("CS_LEVEL").ToString()
                'ONE_TIME_CHARGE,RECCHARGE
            Else
                Dim datatable As DataTable = CustomerInfoFromCustcode(txtMusteriKodu.Text.Trim())
                Label3.Text = Label1.Text
                Label10.Text = txtMusteriKodu.Text.Trim()
                Label4.Text = Label2.Text
                Label9.Text = datatable.Rows(0)("CS_LEVEL").ToString()

            End If

           
        End If
        If DropDownList2.SelectedItem.Text = "Mevcut POFUL detay goster" Then
            Table2.Visible = False
            Table4.Visible = False
            Table3.Visible = True

            Dim dt As DataTable = GetCustomerInfoFromCustcode(txtMusteriKodu.Text.Trim())
            Label5.Text = dt.Rows(0)("CCFNAME").ToString() + " " + dt.Rows(0)("CCLNAME").ToString()
            Label12.Text = txtMusteriKodu.Text.Trim()
            Label13.Text = Label2.Text
            Label11.Text = dt.Rows(0)("CS_LEVEL").ToString()
            Label8.Text = dt.Rows(0)("RPE_LONG_DESC").ToString()
            Label18.Text = dt.Rows(0)("STATUS").ToString() + "   -    " + dt.Rows(0)("DATE").ToString()
            If Label28.Text = "" Then
                Label28.Text = "0"
            Else
                Label28.Text = dt.Rows(0)("ONE_TIME_CHARGE").ToString()

            End If
            If Label29.Text = "" Then
                Label29.Text = "0"
            Else
                Label29.Text = dt.Rows(0)("RECCHARGE").ToString()
            End If







        End If
        If DropDownList2.SelectedItem.Text = "Mevcut POFUL sil" Then

            Table2.Visible = False
            Table3.Visible = False
            Table4.Visible = True


            Dim dt As DataTable = GetCustomerInfoFromCustcode(txtMusteriKodu.Text.Trim())
            Label14.Text = dt.Rows(0)("CCFNAME").ToString() + " " + dt.Rows(0)("CCLNAME").ToString()
            Label15.Text = dt.Rows(0)("CS_LEVEL").ToString()
            'Label15.Text = txtMusteriKodu.Text.Trim()
            Label16.Text = txtMusteriKodu.Text.Trim()
            Label17.Text = dt.Rows(0)("CUSTOMER_ID").ToString()
            Label23.Text = dt.Rows(0)("RPE_LONG_DESC").ToString()
            Label24.Text = dt.Rows(0)("STATUS").ToString() + "   -    " + dt.Rows(0)("DATE").ToString()
            If Label30.Text = "" Then
                Label30.Text = "0"
            Else
                Label30.Text = dt.Rows(0)("ONE_TIME_CHARGE").ToString()

            End If
            If Label31.Text = "" Then
                Label31.Text = "0"
            Else
                Label31.Text = dt.Rows(0)("RECCHARGE").ToString()
            End If





        End If
    End Sub
    Protected Sub btnEkle(sender As Object, e As EventArgs) Handles Button3.Click
        'sncode=1021 // GPRS POFUL   
        Dim dt2 As DataTable = GetCustomerInfoFromCustcode(txtMusteriKodu.Text.Trim())
        Dim dt As DataTable
        dt = CreatePOFULContract(Convert.ToInt32(Label2.Text), DropDownList4.SelectedItem.Text, Convert.ToInt32(DropDownList4.SelectedItem.Value))
        If (dt.Rows.Count > 0) Then
            If (Convert.ToInt32(dt.Rows(0)(0)) <> -1) Then
                Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('POFUL Ekleme Başarıyla Gerçekleşmiştir.');</script>")
                Table3.Visible = False
                Table2.Visible = False
                Us.Visible = False


            Else
                Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('POFUL Ekleme Gerçekleştirilemedi.');</script>")
            End If

        End If
    End Sub
    Protected Sub btnSil(sender As Object, e As EventArgs) Handles Button5.Click

        Dim dt As DataTable
        dt = DeletePOFULContract(Convert.ToInt32(DropDownList6.SelectedItem.Value), Convert.ToInt32(Label17.Text))
        If (dt.Rows.Count > 0) Then
            If (Convert.ToInt32(dt.Rows(0)(0)) <> -1) Then
                Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('POFUL Silme Başarıyla Gerçekleşmiştir.');</script>")
                Table4.Visible = False
                Us.Visible = False
            Else
                Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('POFUL Silme Gerçekleştirilemedi.');</script>")
            End If

        End If
    End Sub

End Class